package com.lingchou.cloud.process.api.controller;

import com.lingchou.cloud.process.api.dto.param.DeployParamVo;
import com.lingchou.cloud.process.api.dto.result.ProcessDefinitionDTO;
import com.lingchou.cloud.process.api.dto.result.ProcessInstanceDTO;
import com.lc.common.bean.response.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 流程发布API
 *
 * @author lc
 */
@RequestMapping(value = "process/v1")
@Api(value = "ProcessDeployApi", tags = "流程发布API")
public interface ProcessDeployApi {

    /**
     * BPMNModel方式 发布流程 并启动
     * @return 流程发布ID
     */
    @ApiOperation(value = "Model方式创建流程定义", notes = "Model方式发布流程，返回流程发布结果，并启动")
    @PostMapping("/deployByModel")
    Result<ProcessInstanceDTO> deployByModelAndStart(@Validated @RequestBody DeployParamVo deployParamVo);

    /**
     * BPMNModel方式 批量发布流程并启动
     * @return 流程发布ID
     */
    @ApiOperation(value = "Model方式批量创建流程定义并启动", notes = "Model方式批量发布流程，返回流程发布结果，并启动")
    @PostMapping("/deployByModelBatch")
    Result<Map<String,ProcessInstanceDTO>> deployByModelAndStartBatch(@Validated @RequestBody List<DeployParamVo> deployParamVos);

    /**
     * 根据XML地址，从文件存储服务获取XML，发布流程
     * @param xmlPath XML地址
     * @return 流程发布ID
     */
    @ApiOperation(value = "XML方式创建流程定义", notes = "根据XML地址，从文件存储服务获取XML，发布流程，返回流程发布id")
    @GetMapping("/deployByXmlPath")
    Result<ProcessDefinitionDTO> deployByXmlPath(@ApiParam(name = "xmlPath", value = "XML地址") @RequestParam String xmlPath);

    /**
     * XML的String 发布流程
     * @param xmlString XML的字符串
     * @return 流程发布ID
     */
    @ApiOperation(value = "XML方式创建流程定义", notes = "XML的String 发布流程，返回流程发布id")
    @GetMapping("/deployByXmlString")
    Result<ProcessDefinitionDTO> deployByXmlString(@ApiParam(name = "xmlString", value = "XML的字符串") @RequestParam String xmlString);


    @GetMapping("/getElements")
    Result<Object> getElements(@RequestParam String defId);
}
